package com.fdb.efp.flow.route.impl;

import com.fdb.efp.flow.route.AbstractRouteRuleExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.fdb.efp.flow.service.vo.BizFlowRouteVO;
import com.fdb.basic.framework.core.constant.BaseConstant;
import com.fdb.basic.framework.core.util.StringUtil;
import com.fdb.efp.rule.common.enumeration.TelAprvQResult;
import com.fdb.efp.rule.service.facade.RuleCallService;

/**
 * 
 * 默认规则执行器
 * 
 * @author Cytus_
 * @since 2018年5月15日 上午10:47:09
 * @version 1.0
 *
 */
@Deprecated
@Service("defaultRouteRuleExector")
public class DefaultRouteRuleExecutor extends AbstractRouteRuleExecutor {

	private static Logger logger = LoggerFactory.getLogger(DefaultRouteRuleExecutor.class);

	@Autowired
	@Qualifier("ruleCallService")
	private RuleCallService ruleCallService;

	@Override
	public boolean routeRuleCall(String bizSerno, String ruleCollId) throws Exception {

		logger.info("业务流水号:" + bizSerno + ", 规则集ID：" + ruleCollId + "调用开始......");
		boolean result = false;
		// TelQuestClsVO qClsVo = new TelQuestClsVO();
		// qClsVo.setBizSerno(bizSerno);
		//
		// TelQuestDtlVO qDtlVo = new TelQuestDtlVO();
		// qDtlVo.setBizSerno(bizSerno);
		//
		// RuleArgsEntity entity = new RuleArgsEntity();
		//
		// try {
		// RuleResultEntity resultEntity = null;// ruleCallService.executeRule(bizSerno,
		// null, ruleCollId, null);
		// result = RuleEntity.PASS.equals(resultEntity.getExecuteReslut());
		// } catch (Exception e) {
		// logger.error("业务流水号：" + bizSerno + "执行规则集：" + ruleCollId + "出现异常!", e);
		// }
		// logger.info("业务流水号:" + bizSerno + ", 规则集ID：" + ruleCollId + "调用结束, 调用结果为:" +
		// result);
		return result;
	}

	public final static TelAprvQResult getTelAprvQResult(String rtl) {
		if (BaseConstant.YES.equals(rtl)) {
			return TelAprvQResult.PASS;
		}
		return TelAprvQResult.NO_PASS;
	}

	@Override
	public boolean isDefault(BizFlowRouteVO routeVo) {
		return StringUtil.isEmpty(routeVo.getBizRouteRule());
	}

}
